package com.woniu.config;//package com.woniu.user.config;
//
//
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.core.convert.converter.Converter;
//import org.springframework.format.FormatterRegistry;
//import org.springframework.web.servlet.config.annotation.CorsRegistry;
//import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
//import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
//
//import java.time.LocalDate;
//import java.time.format.DateTimeFormatter;
//
//@Configuration
//public class WebConfig implements WebMvcConfigurer {
//    @Autowired
//    private LoginInterceptor loginInterceptor;
//
//    @Override
//    public void addCorsMappings(CorsRegistry registry) {
//        registry.addMapping("/**") // 所有接口
//                .allowCredentials(true) // 是否发送 Cookie
//                .allowedOrigins("*") // 支持域
//                .allowedMethods(new String[]{"GET", "POST", "PUT", "DELETE"})
//                .allowedHeaders("*")
//                .exposedHeaders("*");
//    }
//
//    @Override
//    public void addInterceptors(InterceptorRegistry registry) {
//        registry.addInterceptor(loginInterceptor)
//                .addPathPatterns("/**")//那些资源要校验 全部
//                .excludePathPatterns("/account/login") //那些资源放行
//                .excludePathPatterns("/swagger-resources/**", "/webjars/**", "/v2/**", "/swagger-ui.html/**")//swagger 放行
//                .excludePathPatterns("/userInfo/sendRegisterCode","/userInfo/codeRegister","/userInfo/pwdLogin","/userInfo/codeLogin","/userInfo/sendLoginCode")//注册放行
//                .excludePathPatterns("/bookInfo/selectRank")
//                .excludePathPatterns("/orderInfo/notify")
////                .excludePathPatterns("/websocket")
//        ;
//
//    }
////
////    @Override
////    public void addFormatters(FormatterRegistry registry) {
////
////        registry.addConverter(new Converter<String, LocalDate>() {
////            @Override
////            public LocalDate convert(String s) {
////                DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
////                LocalDate localDate2 = LocalDate.parse(s, formatter);
////                return localDate2;
////            }
////        });
////    }
//}
